package com.tbit.uqbike.object.pojo;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 小程序服务通知推送实体类
 *
 * @Author:BUGTian
 * @DATE: 2022/8/3
 */
@Data
public class AppPushParam {
    /**
     * 骑行时间 mock:骑行2分钟
     */
    private String rideTime;

    /**
     * 开锁时间
     */
    private Date startTime;

    /**
     * 关锁时间
     */
    private Date endTime;

    /**
     * 温馨提示
     */
    private String remark;

    public AppPushParam(Date startTime, Date endTime, String remark) {
        this.startTime = startTime;
        this.endTime = endTime;
        this.remark = remark;
        long sTime = startTime.getTime();
        long eTime = endTime.getTime();
        long rideTimeMinute = (((eTime - sTime) / 1000) / 60);
        if ((((eTime - sTime) / 1000) % 60) > 0) {
            rideTimeMinute++;
        }
        rideTime = String.format("骑行%s分钟", rideTimeMinute);
    }

    public Map<String, String> initParam() {
        Map<String, String> map = new HashMap<>(8);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        map.put("thing1", rideTime);
        map.put("time2", sdf.format(startTime));
        map.put("time3", sdf.format(endTime));
        map.put("thing4", remark);
        return map;
    }

}
